<html lang="en">
<title>动态添加表单输入项的测试</title>
<head></head>
<script type="text/javascript">
    function addfile(){
        var files = document.getElementById("files");

        var input = document.createElement("input");
        input.type='file';
        input.name='file';

        var btn = document.createElement("input");
        btn.type='button';
        btn.value='删除';
        btn.onclick = function del(){
            this.parentNode.parentNode.removeChild(this.parentNode);
        }

        var div = document.createElement("div");
        div.appendChild(input);
        div.appendChild(btn);

        files.appendChild(div);

    }



</script>
<body>
<table>
    <tr>
        <td>上传用户</td>
        <td>
            <input type="text" name="username">
        </td>
    </tr>
    <tr>
        <td>上传文件</td>
        <td>
            <input type="button" value="添加上传文件" onclick="addfile()">
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <div id="files"></div>
        </td>
    </tr>

</table>


</body>

</html>